#include "PipePositionModel.h"

PipePositionModel* PipePositionModel::ppm = NULL;

PipePositionModel* PipePositionModel::initInstance(vector3 emergePoint, float pipeLength, float width){
	if (ppm == NULL){
		ppm = new PipePositionModel(emergePoint, pipeLength, width);
	}
	return ppm;
}

PipePositionModel* PipePositionModel::getInstance(){
	if (ppm == NULL){
		ppm = new PipePositionModel();
	}
	return ppm;
}

vector3 PipePositionModel::getPosition(){
	vector3 pos;
	int modX = pipeLength * 100;
	pos.x = (float)(rand() % modX) / 100 + emergePoint.x;

	int modY = width * 100;
	pos.y = (float)(rand() % modY) / 100 + emergePoint.y - width / 2;

	int modZ = width * 100;
	pos.z = (float)(rand() % modZ) / 100 + emergePoint.z - width / 2;

	return pos;
}

vector3 PipePositionModel::getVelocity(){
	vector3 vel = vector3(-1, 0, 0);
	vel *= this->velocity;
	return vel;
}